import { storageGenerator } from '@/utils/cache';
import { defineStore } from 'pinia';

export const useArtifactRepositoryStore = defineStore('artifactRepository', {
  state: () => {
    return {
      artifactObj: <any>{},
    };
  },
  getters: {
    getArtifactObjData(): any {
      return this.artifactObj ?? null;
    },
  },
  actions: {
    setArtifactObjData(info: any) {
      this.artifactObj = { ...info };
    },
  },
  // 配置是否存入本地缓存，默认存入sessionStorage，具体使用参考文档 https://seb-l.github.io/pinia-plugin-persist/
  persist: {
    enabled: true,
    strategies: [{ storage: storageGenerator('artifactRepository'), paths: ['artifactObj'] }],
  },
});
